#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n = 0, x = 0;
    cin >> n >> x;
    vector<int> arr(n + 1);
    for(int i = 1; i <= n; ++i)
    {
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
    int index = max(0, n - x); // 处理 x 过⼤的情况
    long long ret = arr[index] * x;
    for(int i = index + 1; i <= n; ++i)
    {
        ret += arr[i] - arr[index];
    }
    cout << ret;
    return 0;
}